<?php

namespace Home\Controller;

class IndexController extends BaseController {

    public function getBanner() {
        $data = M('Ad')->field('ad_id,ad_img,ad_title,ad_link')->where(array("postion_id" => 1))->select();

        if (!empty($data)) {
            foreach ($data as &$val) {
                $val['ad_img'] = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__ . $val['ad_img'];
                $val['ad_link'] = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__ ."/index.php?s=/Home/Public/bannerInfo/ad_id/{$val['ad_id']}";
            }
            unset($val);
        }
        
        $this->success('成功',$data);
    }

}
